package com.woniuxy.kaer.service.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.kaer.commons.util.Result;
import com.woniuxy.kaer.service.dto.ServiceBaseDto;
import com.woniuxy.kaer.service.entity.ServiceBase;
import com.woniuxy.kaer.service.from.AddServiceBaseFrom;
import com.woniuxy.kaer.service.param.AddServiceBaseParam;
import com.woniuxy.kaer.service.service.ServiceBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 程诗洋
 * @since 2025年02月17日
 */
//服务基本信息接口
@RestController
@RequestMapping("/serviceBase")
@Api(tags = "服务基本信息接口")
public class ServiceBaseController {
    @Resource
    private ServiceBaseService serviceBaseService;
    @PostMapping("/AddServiceBase")
    @ApiOperation("新增服务类别接口")
    public Result AddServiceBase(AddServiceBaseFrom from)throws Exception{
        System.out.println(from.getServiceBaseName());
        AddServiceBaseParam addServiceBaseParam = BeanUtil.toBean(from, AddServiceBaseParam.class);
        serviceBaseService.AddServiceBase(addServiceBaseParam);
        return Result.succeed("新增服务类别成功",null);
    }
    //通过关键字查询服务类别，得出商铺Id
    @ApiOperation("通过关键字查询服务类别，得出商铺Id")
    @GetMapping("/getServiceBaseByServiceName")
    public Result<List<Integer>> getServiceBaseByServiceName(String serviceName)throws Exception{
        List<Integer> shopIds = serviceBaseService.getServiceBaseByServiceName(serviceName);
        return Result.succeed("查询成功",shopIds);
    }

    //根据商铺Id查询服务类别
    @ApiOperation("根据商铺Id查询服务类别")
    @GetMapping("/getServiceBaseByShopId")
    public Result getServiceBaseByShopId(Integer shopId)throws Exception{
        List<ServiceBase> serviceBaseIds = serviceBaseService.getServiceBaseByShopId(shopId);
        return Result.succeed("查询成功",serviceBaseIds);
    }
    ////输入商铺查询，商铺的所有服务项目
    @ApiOperation("根据店铺Id查询店铺所有服务")
    @GetMapping("/getServiceBaseByShopIdAndServiceName")
    public Result<List<ServiceBaseDto>> getServiceBaseByShopIdAndServiceName(Integer shopId)throws Exception{
        List<ServiceBaseDto> serviceBaseIds = serviceBaseService.getServiceBaseByShopIdAndServiceName(shopId);
        return Result.succeed("查询成功",null);
    }
}

